#version 430

in vec3 p3d_Normal;
in vec4 p3d_Vertex;
in vec4 p3d_Color;

layout(std430, binding=1) buffer te
{
    vec4 temp[];
};

//~ uniform vec3 temp[300];

uniform mat4 p3d_ModelMatrix;
uniform mat4 p3d_ModelViewMatrix;
//~ uniform mat4 p3d_ProjectionMatrix;
uniform mat4 p3d_ModelViewProjectionMatrix;
uniform mat4 p3d_ModelViewMatrixInverseTranspose;


out vec3 normal;
out vec4 position;
out vec3 eye_normal;
out vec4 eye_position;
out vec4 color;




void main()
{
    vec4 dp = temp[gl_InstanceID];
    //~ vec3 dp = vec3(float(gl_InstanceID), 0, 0);
    vec4 vertex = p3d_Vertex  + dp;
    gl_Position = p3d_ModelViewProjectionMatrix * vertex;
    position = p3d_ModelMatrix * vertex;
    normal = normalize(mat3(p3d_ModelMatrix) * p3d_Normal);
    eye_position = p3d_ModelViewMatrix * vertex;
    eye_normal = normalize(mat3(p3d_ModelViewMatrix) * p3d_Normal);
    color = p3d_Color;
}
